home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / gnuplsrc.zip / GNUSHELL.C < prev    next >
C/C++ Source or Header  |  1993-03-21  |  6KB  |  212 lines

  1. #ifdef INCRCSDATA
  2. static char RCSid[]="$Id: gnushell.c,v 1.2 1992/07/26 12:37:10 fearick Exp fearick $" ;
  3. #endif
  4.  
  5. /****************************************************************************
  6.  
  7.     PROGRAM: gnushell
  8.     
  9.  
  10.     a shell for gnuplot to allow plotting on pm with minimum hassle
  11.  
  12.     MODULE:  gnushell.c
  13.         
  14.     This file contains the startup procedures for gnushell
  15.  
  16.  
  17.     Copyright (c) 1992, Roger Fearick.
  18.     All rights reserved
  19.      
  20.     THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT WARRANTIES OF ANY KIND. 
  21.    
  22.     Permission is hereby granted for personal, non-commercial use of this 
  23.     software.You are granted the right to use, modify, and redistribute 
  24.     it for for non-commercial purposes, provided that all copyright 
  25.     notices remain intact and all changes are clearly documented.      
  26.     THE AUTHOR MAKES NO WARRANTY OF ANY KIND WITH RESPECT TO THIS PRODUCT 
  27.     AND EXPLICITLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY 
  28.     OR FITNESS FOR ANY PARTICULAR PURPOSE.                               
  29.    
  30. ****************************************************************************/
  31.  
  32. /* Update Log
  33. **
  34.  * $Log: gnushell.c,v $
  35.  * Revision 1.2  1992/07/26  12:37:10  fearick
  36.  * Initial 32-bit version
  37.  *
  38.  * Revision 1.1  1992/07/25  15:43:33  fearick
  39.  * Initial revision
  40.  *
  41.  *
  42. */ 
  43.  
  44. #define INCL_PM
  45. #define INCL_WIN
  46. #define INCL_DOSMEMMGR
  47. #define INCL_DOSPROCESS
  48. #define INCL_DOSFILEMGR
  49. #include <os2.h>
  50. #include <string.h>
  51. #include <stdio.h>
  52. #include <stdlib.h>
  53. #include "gnushell.h"
  54.  
  55.         /* identification */
  56.  
  57. #define APP_NAME            "GnuShell"
  58.  
  59. /*==== l o c a l    d a t a ==================================================*/
  60.  
  61.             /* class names for window registration */
  62.  
  63. static char szChildName []     = "Gnuchild" ;
  64.  
  65. /*==== f u n c t i o n s =====================================================*/
  66.  
  67.  
  68. int              main( void ) ;
  69. static HWND      InitHelp( HAB, HWND ) ;
  70.  
  71. MRESULT EXPENTRY NewFrameWndProc(HWND, ULONG, MPARAM, MPARAM) ;
  72. MRESULT EXPENTRY About(HWND, ULONG, MPARAM, MPARAM);
  73.  
  74.  
  75. /*==== c o d e ===============================================================*/
  76.  
  77. int main (  )
  78. /*
  79. ** 
  80. ** Standard PM initialisation:
  81. ** -- set up message processing loop
  82. ** -- register all window classes
  83. ** -- start up main window
  84. ** -- subclass main window for help and dde message trapping to frame window
  85. ** -- init help system
  86. ** -- check command line and open any filename found there
  87. **
  88. */
  89. {
  90.     static ULONG flFrameFlags = (FCF_ACCELTABLE|FCF_STANDARD);//&(~FCF_TASKLIST) ;
  91.     static ULONG flClientFlags = WS_VISIBLE ;
  92.     HMQ          hmq ;
  93.     QMSG         qmsg ;
  94.     PFNWP        pfnOldFrameWndProc ;
  95.     HWND         hwndHelp ;        
  96.  
  97.     hab = WinInitialize( 0 ) ;    
  98.     hmq = WinCreateMsgQueue( hab, 50 ) ;
  99.  
  100.                 // register window and child window classes
  101.  
  102.     if( ! WinRegisterClass( hab,        /* Exit if can't register */
  103.                             APP_NAME,
  104.                             (PFNWP)DisplayClientWndProc,
  105.                             CS_SIZEREDRAW,
  106.                             0 ) 
  107.                             ) return 0L ;
  108.  
  109.                 // create main window
  110.  
  111.     hwndFrame = WinCreateStdWindow (
  112.                     HWND_DESKTOP,
  113.                     WS_VISIBLE,
  114.                     &flFrameFlags,
  115.                     APP_NAME,
  116.                     NULL,
  117.                     flClientFlags,
  118.                     0L,
  119.                     1,
  120.                     &hApp) ;
  121.  
  122.     if ( ! hwndFrame ) return NULL ;
  123.  
  124.                 // subclass window for help & DDE trapping
  125.  
  126.     pfnOldFrameWndProc = WinSubclassWindow( hwndFrame, (PFNWP)NewFrameWndProc ) ;
  127.     WinSetWindowULong( hwndFrame, QWL_USER, (ULONG) pfnOldFrameWndProc ) ;
  128.  
  129.                 // init the help manager
  130.  
  131.     hwndHelp = InitHelp( hab, hwndFrame ) ;        
  132.  
  133.                 // set window title and make it active
  134.  
  135.     WinSetWindowText( hwndFrame, APP_NAME ) ;
  136.     WinSetActiveWindow( HWND_DESKTOP, hwndFrame ) ;
  137.     
  138.                 // process window messages 
  139.       
  140.     while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
  141.          WinDispatchMsg (hab, &qmsg) ;
  142.  
  143.                 // shut down
  144.  
  145.     WinDestroyHelpInstance( hwndHelp ) ;
  146.     WinDestroyWindow (hwndFrame) ;
  147.     WinDestroyMsgQueue (hmq) ;
  148.     WinTerminate (hab) ;
  149.  
  150.     return 0 ;
  151.     }
  152.  
  153. static HWND InitHelp( HAB hab, HWND hwnd )
  154. /*
  155. **  initialise the help system
  156. */
  157.     {
  158.     static HELPINIT helpinit = { sizeof(HELPINIT),
  159.                                  0L,
  160.                                  NULL,
  161.                                  (PHELPTABLE)MAKELONG(1, 0xFFFF),
  162.                                  0L,
  163.                                  0L,
  164.                                  0,
  165.                                  0,
  166.                                  "Gnushell Help",
  167.                                  CMIC_HIDE_PANEL_ID,
  168.                                  "gnushell.hlp" } ;
  169.     HWND hwndHelp ;
  170.     
  171.     hwndHelp = WinCreateHelpInstance( hab, &helpinit ) ;
  172.     WinAssociateHelpInstance( hwndHelp, hwnd ) ;
  173.     return hwndHelp ;
  174.     }
  175.  
  176. MRESULT EXPENTRY NewFrameWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  177. /*
  178. **  Subclasses top-level frame window to trap help & dde messages
  179. */
  180.     {
  181.     PFNWP       pfnOldFrameWndProc ;
  182.     
  183.     pfnOldFrameWndProc = (PFNWP) WinQueryWindowULong( hwnd, QWL_USER ) ; 
  184.     switch( msg ) {
  185.         default: 
  186.             break ;
  187.  
  188.         case HM_QUERY_KEYS_HELP:
  189.             return (MRESULT) IDH_KEYS ;            
  190.         }
  191.     return (*pfnOldFrameWndProc)(hwnd, msg, mp1, mp2) ;    
  192.     }
  193.  
  194.  
  195. MRESULT EXPENTRY About( HWND hDlg, ULONG message, MPARAM mp1, MPARAM mp2)
  196. /*
  197. ** 'About' box dialog function -- basically generic
  198. */
  199.     {
  200.     switch (message) {
  201.  
  202.         case WM_COMMAND:
  203.             if (SHORT1FROMMP(mp1) == DID_OK) {
  204.                 WinDismissDlg( hDlg, DID_OK );
  205.                 return 0L;
  206.                 }
  207.             break;
  208.         }
  209.     return WinDefDlgProc( hDlg, message, mp1, mp2 ) ;
  210.     }
  211.  
  212.